// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: GHZ Setup Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

private alias Object.Value0 : Object.Timer
private alias Object.Value1 : Attack.Timer
private alias Object.Value2 : Mercy.Attack
private alias Object.Value3 : Wait.Time
private alias Object.Value4 : Attack.Direction 
private alias Object.Value5 : Green.Shit
private alias Object.Value7 : Direct.Var

private alias Object[40].Value33 : Object.AttackTimer
private alias Object[40].Value28 : Object.TableContainer
private alias object.value6 : player.invulnerable


reserve function DeltaAttacks_SummonMercy

// State aliases
private alias 0  : DELTAATTACKS_PROJECTILE_0
private alias 1  : DELTAATTACKS_PROJECTILE_MERCY_1
private alias 2  : DELTAATTACKS_THUNDERALERT_2
private alias 3  : DELTAATTACKS_FASTTHUNDER_3
private alias 4  : DELTAATTACKS_TREE_UP_4
private alias 5  : DELTAATTACKS_TREE_DOWN_5
private alias 6  : DELTAATTACKS_TREE_RIGHT_6
private alias 7  : DELTAATTACKS_TREE_LEFT_7
private alias 8  : DELTAATTACKS_TREE_L_ALT_8

private alias 0  : FREDDYATTACKS_PROJECTILE_0
private alias 1  : FREDDYATTACKS_PROJECTILE_MERCY_1
private alias 2  : FREDDYATTACKS_MIKETOSS_2
private alias 3  : FREDDYATTACKS_LEFTTOSS_3
private alias 4  : FREDDYATTACKS_HARHAR_4
private alias 5  : FREDDYATTACKS_PIZZAWHEEL_5

public value Delta_HP = 90;
public value Delta_YourTurn = 1;
public value Delta_SlenderMercy = 0;

function DeltaAttacks_SummonMercy

	Attack.Timer++
	if Attack.Timer == 100
		temp1 = screen.xcenter
		temp1 *= 0x19000
		temp2 = Screen.ycenter
		temp2 *= 0x10000

	
		CreateTempObject(TypeName[Freddy Attacks], 1, temp1, temp2)
		object[tempObjectPos].state = 2
		object[tempObjectPos].drawOrder = 6	
		
		Attack.Timer = 0
	end if

end function

event ObjectMain
if object[40].state == 6
	Object.Priority = PRIORITY_ACTIVE
	object.drawOrder = 6
	Object.Xpos += Object.xvel
	Object.Ypos += Object.Yvel
	//slenderman
		if Delta_Attacker == 0
			switch object.propertyValue
			case DELTAATTACKS_PROJECTILE_0
			case DELTAATTACKS_PROJECTILE_MERCY_1
				switch object.state
				case 0

					if Delta_AttackHardMode == 1
						Wait.Time = 50
					else
						Wait.Time = 65
					end if

					Attack.Timer++
					if Attack.Timer >= Wait.Time
						temp1 = screen.xcenter
						temp1 *= 0x19000
						temp2 = Screen.ycenter
						temp2 *= 0x10000

					
						if Delta_BecomeGreen == 1
							rand(Mercy.Attack, 4)		//4 =	0, 1, 2, 3
							if Mercy.Attack == 3	//25% chance
								Mercy.Attack = 1
							end if
						end if
					
						
						CreateTempObject(TypeName[Freddy Attacks], 0, temp1, temp2)
						if Mercy.Attack == 1
							object.state = 2
						else
							object.state++	
						end if
						object[tempObjectPos].drawOrder = 6	
						
						Attack.Timer = 0
					end if			
				case 1	//normal evil attack
					object.timer++

					if object.timer <= 200
						CheckGreater(object.xpos, object[currentPlayer].xpos)
						temp0 = checkResult
						if temp0 == 1		//right
							if object.xvel > 0
								object.xvel -= 0x1000	//right
								if object.xvel > 0x4000
									object.xvel = 0x4000
								end if
							else
								object.xvel -= 0x500	//left?? i have no clue
								if object.xvel > 0x5000
									object.xvel = 0x5000
								end if			
							end if
						else	//left
							if object.xvel < 0
								object.xvel += 0x2000
								if object.xvel > 0x4000
									object.xvel = 0x4000
								end if		
							else
								object.xvel += 0x1500
								if object.xvel > 0x4000
									object.xvel = 0x4000
								end if								
							end if
						end if

						CheckGreater(object.ypos, object[currentPlayer].ypos)
						temp0 = checkResult

						if temp0 == 1		//right
							if object.yvel > 0
								object.yvel -= 0x2000	
							else
								object.yvel -= 0x1500	
							end if		
						else		//down
							if object.yvel < 0
								object.yvel += 0x2000
							else
								object.yvel += 0x1500
							end if
						end if	
					end if


					if object.timer == 400
						object.type = TypeName[Blank Object]
						object.timer = 0	
					end if

				break
				case 2	//happy attack
					CheckGreater(object.xpos, object[currentPlayer].xpos)
					temp0 = checkResult
					if temp0 == 1		//right
						if object.xvel > 0
							object.xvel -= 0x1000	//right
							if object.xvel > 0x4000
								object.xvel = 0x4000
							end if
						else
							object.xvel -= 0x500	//left?? i have no clue
							if object.xvel > 0x5000
								object.xvel = 0x5000
							end if			
						end if
					else	//left
						if object.xvel < 0
							object.xvel += 0x2000
							if object.xvel > 0x4000
								object.xvel = 0x4000
							end if		
						else
							object.xvel += 0x1500
							if object.xvel > 0x4000
								object.xvel = 0x4000
							end if								
						end if
					end if

					CheckGreater(object.ypos, object[currentPlayer].ypos)
					temp0 = checkResult

					if temp0 == 1		//right
						if object.yvel > 0
							object.yvel -= 0x2000	
						else
							object.yvel -= 0x1500	
						end if		
					else		//down
						if object.yvel < 0
							object.yvel += 0x2000
						else
							object.yvel += 0x1500
						end if
					end if	
				break			
				end switch
				

				foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)	
					if object.state == 2
						BoxCollisionTest(C_TOUCH, object.entityPos, -6, -6, 6, 6, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
						if checkResult == 1
							if Delta_Attacker == 0
								Delta_SlenderMercy += 5
							else
								Delta_FreddyMercy += 5
								if Delta_HP < 90
									Delta_HP += 2
								end if								
							end if
							if ringPan == 0
								PlaySfx(SfxName[Ring L], 0)
								SetSfxAttributes(SfxName[Ring L], -1, -100)
								ringPan = 1
							else
								PlaySfx(SfxName[Ring R], 0)
								SetSfxAttributes(SfxName[Ring R], -1, 100)
								ringPan = 0
							end if			
							Delta_ShowMercy = 1			
							Object.TableContainer = 0
							object.type = TypeName[Blank Object]	
						end if
					else
						if object[currentPlayer].value6 == 0
							BoxCollisionTest(C_TOUCH, object.entityPos, -6, -6, 6, 6, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
							if checkResult == 1
								if Delta_Defending == 1
									Delta_HP--
								else
									Delta_HP -= 2
								end if
								PlaySfx(SfxName[Hurt], 0)
								object[40].AnimationTimer = 80
								object[40].Animation = 2
								object[currentPlayer].value6	= 80
							end if
						end if
					end if
				next		
			break
			case DELTAATTACKS_THUNDERALERT_2
			case DELTAATTACKS_FASTTHUNDER_3
				if Delta_AttackHardMode == 1
					Attack.Timer = 15
				else	
					Attack.Timer = 20
				end if

				switch object.state
					case 0	//spawning in,	
						object.timer++
						Object.Xpos = object[currentPlayer].xpos
						temp0 = screen.ycenter
						temp0 *= 0x9900
						Object.Ypos = temp0
						if object.timer == Attack.Timer
							playsfx(SfxName[Warning], 0)
							object.state++
							object.timer = 0
						end if
					break
					case 1	//wait a sec
						object.timer++
						if object.timer == Attack.Timer	
							playsfx(SfxName[SlenderThunder], 0)

							if Delta_BecomeGreen == 1
								rand(Mercy.Attack, 4)		//4 =	0, 1, 2, 3
								if Mercy.Attack == 3	//25% chance
									Mercy.Attack = 1
								end if
							end if				
							if mercy.attack == 1	
								object.state = 3
							else
								object.state++
							end if
							object.timer = 0
						end if
					break
					case 2
						object.timer++
						if object.timer == Attack.Timer
							object.state = 0
							object.timer = 0
						end if

						foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)	
							if object[currentPlayer].value6 == 0
								BoxCollisionTest(C_TOUCH, object.entityPos, -10, -6, 10, 71, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
								if checkResult == 1
									if Delta_Defending == 1
										Delta_HP-= 2
									else
										Delta_HP -= 4
									end if
									PlaySfx(SfxName[Hurt], 0)
									object[40].AnimationTimer = 80
									object[40].Animation = 2
									object[currentPlayer].value6	= 80
								end if
							end if
						next
					break
					case 3
						object.timer++
						temp0 = Attack.Timer
						temp0 *= 3
						if object.timer == temp0
							object.state = 0
							object.timer = 0
						end if

						foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)	
							BoxCollisionTest(C_TOUCH, object.entityPos, -10, -6, 10, 71, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
							if checkResult == 1
								if Delta_Attacker == 0
									Delta_SlenderMercy += 5
								else
									Delta_FreddyMercy += 5
									if Delta_HP < 90
										Delta_HP += 2
									end if									
								end if
								if ringPan == 0
									PlaySfx(SfxName[Ring L], 0)
									SetSfxAttributes(SfxName[Ring L], -1, -100)
									ringPan = 1
								else
									PlaySfx(SfxName[Ring R], 0)
									SetSfxAttributes(SfxName[Ring R], -1, 100)
									ringPan = 0
								end if			
								Delta_ShowMercy = 1			
								Object.TableContainer = 0

								temp1 = screen.xcenter
								temp1 *= 0x19000
								temp2 = Screen.ycenter
								temp2 *= 0x10000
								//what?
								Mercy.Attack = 0
								if object.propertyValue == 3
									CreateTempObject(TypeName[Freddy Attacks], 3, temp1, temp2)
								else
									CreateTempObject(TypeName[Freddy Attacks], 2, temp1, temp2)
								end if	
								object[tempObjectPos].Value2 = 0

								object.type = TypeName[Blank Object]
							end if
						next
					break			
				end switch
			break
			case DELTAATTACKS_TREE_UP_4
				switch object.state 
					case 0
						object.timer++
						Object.Xpos = object[currentPlayer].xpos

						object.alpha += 4

						if object.timer >= Wait.Time
							object.state++
							PlaySfx(SfxName[Release],0)
							object.timer = 0
							object.alpha = 255
						end if
					break
					case 1
						object.ypos += object.yvel
						object.yvel -= 0x1600

						if object.outofbounds == 1
							temp1 = screen.xcenter
							temp1 *= 0x19000
							temp2 = Screen.ycenter
							temp2 *= 0x10000

							CreateTempObject(TypeName[Freddy Attacks], 4, temp1, temp2)
							object[tempObjectPos].state = 0
							object[tempObjectPos].alpha = 0
							object[tempObjectPos].value3 = 75
							object[tempObjectPos].drawOrder = 6	
							object.type = TypeName[Blank Object]
						end if
					break			
				end switch

				if Delta_BecomeGreen == 1
					Callfunction(DeltaAttacks_SummonMercy)
				end if

				foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)	
					BoxCollisionTest(C_TOUCH, object.entityPos, -12, 24, 12, 84, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
					if object[currentPlayer].value6 == 0
						if checkResult == 1
							if Delta_Defending == 1
								Delta_HP-= 1
							else
								Delta_HP -= 2
							end if
							PlaySfx(SfxName[Hurt], 0)
							object[40].AnimationTimer = 80
							object[40].Animation = 2
							object[currentPlayer].value6	= 80
						end if
					end if
				next
			break
			case DELTAATTACKS_TREE_DOWN_5
				switch object.state 
					case 0
						object.timer++
						Object.Xpos = object[currentPlayer].xpos
						temp2 = -0x200000
						Object.Ypos = temp2

						object.alpha += 4

						if object.timer >= Wait.Time
							object.state++
							PlaySfx(SfxName[Release],0)
							object.timer = 0
							object.alpha = 255
						end if
					break
					case 1
						object.timer++

						object.ypos += object.yvel
						object.yvel += 0x1600


						if object.outofbounds == 1
							temp1 = screen.xcenter
							temp1 *= 0x19000
							temp2 = Screen.ycenter
							temp2 *= 0x10000

						
							CreateTempObject(TypeName[Freddy Attacks], 5, temp1, temp2)
							object[tempObjectPos].state = 0
							object[tempObjectPos].alpha = 0
							object[tempObjectPos].value3 = 75
							object[tempObjectPos].drawOrder = 6	
							object.type = TypeName[Blank Object]
						end if
					break			
				end switch

				if Delta_BecomeGreen == 1
					Callfunction(DeltaAttacks_SummonMercy)
				end if		

				foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)	
					BoxCollisionTest(C_TOUCH, object.entityPos, -12, 24, 12, 84, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
					if object[currentPlayer].value6 == 0
						if checkResult == 1
							if Delta_Defending == 1
								Delta_HP-= 1
							else
								Delta_HP -= 2
							end if
							PlaySfx(SfxName[Hurt], 0)
							object[40].AnimationTimer = 80
							object[40].Animation = 2
							object[currentPlayer].value6	= 80
						end if
					end if
				next

			break
			case DELTAATTACKS_TREE_RIGHT_6
				switch object.state 
					case 0
						object.timer++
						Object.Ypos = object[currentPlayer].Ypos
						temp2 = 0x400000
						Object.Xpos = temp2

						object.alpha += 4

						if object.timer >= Wait.Time
							object.state++
							PlaySfx(SfxName[Release],0)
							object.timer = 0
							object.alpha = 255
						end if
					break
					case 1
						object.timer++

						object.xpos += object.xvel
						object.xvel += 0x2000


						if object.outofbounds == 1
							temp1 = screen.xcenter
							temp1 *= 0x19000
							temp2 = Screen.ycenter
							temp2 *= 0x10000

						
							CreateTempObject(TypeName[Freddy Attacks], 7, temp1, temp2)
							object[tempObjectPos].state = 0
							object[tempObjectPos].alpha = 0
							object[tempObjectPos].value3 = 25
							object[tempObjectPos].drawOrder = 6	
							object.type = TypeName[Blank Object]
						end if
					break				
				end switch

				if Delta_BecomeGreen == 1
					Callfunction(DeltaAttacks_SummonMercy)
				end if

				foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)	
					BoxCollisionTest(C_TOUCH, object.entityPos, 24, -12, 84, 12, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
					if object[currentPlayer].value6 == 0
						if checkResult == 1
							if Delta_Defending == 1
								Delta_HP-= 1
							else
								Delta_HP -= 2
							end if
							PlaySfx(SfxName[Hurt], 0)
							object[40].AnimationTimer = 80
							object[40].Animation = 2
							object[currentPlayer].value6	= 80
						end if
					end if
				next

			break
			case DELTAATTACKS_TREE_LEFT_7

				switch object.state 
					case 0
						object.timer++
						Object.Ypos = object[currentPlayer].Ypos
						temp2 = 16000000
						Object.Xpos = temp2

						object.alpha += 4

						if object.timer >= Wait.Time
							object.state++
							PlaySfx(SfxName[Release],0)
							object.timer = 0
							object.alpha = 255
						end if
					break
					case 1
						object.timer++

						object.xpos += object.xvel
						object.xvel -= 0x2000


						if object.outofbounds == 1
							temp1 = screen.xcenter
							temp1 *= 0x19000
							temp2 = Screen.ycenter
							temp2 *= 0x10000

						
							CreateTempObject(TypeName[Freddy Attacks], 6, temp1, temp2)
							object[tempObjectPos].state = 0
							object[tempObjectPos].alpha = 0
							object[tempObjectPos].value3 = 25
							object[tempObjectPos].drawOrder = 6	
							object.type = TypeName[Blank Object]
						end if
					break				
				end switch

				if Delta_BecomeGreen == 1
					Callfunction(DeltaAttacks_SummonMercy)
				end if


				foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)	
					BoxCollisionTest(C_TOUCH, object.entityPos, 24, -12, 84, 12, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
					if object[currentPlayer].value6 == 0
						if checkResult == 1
							if Delta_Defending == 1
								Delta_HP-= 1
							else
								Delta_HP -= 2
							end if
							PlaySfx(SfxName[Hurt], 0)
							object[40].AnimationTimer = 80
							object[40].Animation = 2
							object[currentPlayer].value6	= 80
						end if
					end if
				next

			break	
			end switch
	else
	//hey guys im freddy
		switch object.propertyValue
			case FREDDYATTACKS_PROJECTILE_0
			case FREDDYATTACKS_PROJECTILE_MERCY_1
				switch object.state
				case 0
					if Delta_AttackHardMode == 1
						Wait.Time = 45
					else
						Wait.Time = 65
					end if

					Attack.Timer++
					if Attack.Timer >= Wait.Time
						temp1 = screen.xcenter
						temp1 *= 0x19000
						temp2 = Screen.ycenter
						temp2 *= 0x10000

					
						if Delta_BecomeGreen == 1
							rand(Mercy.Attack, 4)		//4 =	0, 1, 2, 3
							if Mercy.Attack == 3	//25% chance
								Mercy.Attack = 1
							end if
						end if
					
						
						CreateTempObject(TypeName[Freddy Attacks], 0, temp1, temp2)
						if Mercy.Attack == 1
							object.state = 2
						else
							object.state++	
						end if
						object[tempObjectPos].drawOrder = 6	
						
						Attack.Timer = 0
					end if	
				case 1	//normal evil attack
					object.timer++

					if object.timer <= 200
						CheckGreater(object.xpos, object[currentPlayer].xpos)
						temp0 = checkResult
						if temp0 == 1		//right
							if object.xvel > 0
								object.xvel -= 0x1000	//right
								if object.xvel > 0x4000
									object.xvel = 0x4000
								end if
							else
								object.xvel -= 0x500	//left?? i have no clue
								if object.xvel > 0x5000
									object.xvel = 0x5000
								end if			
							end if
						else	//left
							if object.xvel < 0
								object.xvel += 0x2000
								if object.xvel > 0x4000
									object.xvel = 0x4000
								end if		
							else
								object.xvel += 0x1500
								if object.xvel > 0x4000
									object.xvel = 0x4000
								end if								
							end if
						end if

						CheckGreater(object.ypos, object[currentPlayer].ypos)
						temp0 = checkResult

						if temp0 == 1		//right
							if object.yvel > 0
								object.yvel -= 0x2000	
							else
								object.yvel -= 0x1500	
							end if		
						else		//down
							if object.yvel < 0
								object.yvel += 0x2000
							else
								object.yvel += 0x1500
							end if
						end if	
					end if


					if object.timer == 400
						object.type = TypeName[Blank Object]
						object.timer = 0	
					end if

				break
				case 2	//happy attack
					CheckGreater(object.xpos, object[currentPlayer].xpos)
					temp0 = checkResult
					if temp0 == 1		//right
						if object.xvel > 0
							object.xvel -= 0x1000	//right
							if object.xvel > 0x4000
								object.xvel = 0x4000
							end if
						else
							object.xvel -= 0x500	//left?? i have no clue
							if object.xvel > 0x5000
								object.xvel = 0x5000
							end if			
						end if
					else	//left
						if object.xvel < 0
							object.xvel += 0x2000
							if object.xvel > 0x4000
								object.xvel = 0x4000
							end if		
						else
							object.xvel += 0x1500
							if object.xvel > 0x4000
								object.xvel = 0x4000
							end if								
						end if
					end if

					CheckGreater(object.ypos, object[currentPlayer].ypos)
					temp0 = checkResult

					if temp0 == 1		//right
						if object.yvel > 0
							object.yvel -= 0x2000	
						else
							object.yvel -= 0x1500	
						end if		
					else		//down
						if object.yvel < 0
							object.yvel += 0x2000
						else
							object.yvel += 0x1500
						end if
					end if	
				break			
				end switch
				

				foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)	
					if object.state == 2
						BoxCollisionTest(C_TOUCH, object.entityPos, -6, -6, 6, 6, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
						if checkResult == 1
							if Delta_Attacker == 0
								Delta_SlenderMercy += 5
							else
								Delta_FreddyMercy += 5
								if Delta_HP < 90
									Delta_HP += 2
								end if
							end if
							if ringPan == 0
								PlaySfx(SfxName[Ring L], 0)
								SetSfxAttributes(SfxName[Ring L], -1, -100)
								ringPan = 1
							else
								PlaySfx(SfxName[Ring R], 0)
								SetSfxAttributes(SfxName[Ring R], -1, 100)
								ringPan = 0
							end if			
							Delta_ShowMercy = 1			
							Object.TableContainer = 0
							object.type = TypeName[Blank Object]	
						end if
					else
						if object[currentPlayer].value6 == 0
							BoxCollisionTest(C_TOUCH, object.entityPos, -6, -6, 6, 6, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
							if checkResult == 1
								if Delta_Defending == 1
									Delta_HP--
								else
									Delta_HP -= 2
								end if
								PlaySfx(SfxName[Hurt], 0)
								object[40].AnimationTimer = 80
								object[40].Animation = 2
								object[currentPlayer].value6	= 80
							end if
						end if
					end if
				next	
			break
			case FREDDYATTACKS_MIKETOSS_2
				switch object.state
					case 0
						if Delta_AttackHardMode == 1
							Wait.Time = 35
						else
							Wait.Time = 50
						end if

						Attack.Timer++
						if Attack.Timer >= Wait.Time
							temp1 = screen.xcenter
							temp1 *= 0x19000
							temp2 = object[currentPlayer].ypos

							if Delta_BecomeGreen == 1
								rand(Mercy.Attack, 5)		//4 =	0, 1, 2, 3
								if Mercy.Attack == 4	//25% chance
									Mercy.Attack = 1
								end if
							end if
						
							
							CreateTempObject(TypeName[Freddy Attacks], 2, temp1, temp2)
							if Mercy.Attack == 1
								Green.Shit = 1
							end if
							object.state++	
							

							Attack.Timer = 0
						end if	
					//ok so there should usually be a break here but like, it kinda makes it work not as good??
					//but idk if this would do anything back
					case 1	//normal evil attack
						object.timer++

						if object.timer <= 150
							object.rotation -= 12
							object.xvel -= 0x600	//left?? i have no clue
							if object.xvel > 0x8000
								object.xvel = 0x8000
							end if			
						else
							object.rotation += 12
							object.xvel += 0x2000
							if object.xvel > 0x20000
								object.xvel = 0x20000
							end if		
						end if


						if object.timer == 400
							object.type = TypeName[Blank Object]
							object.timer = 0	
						end if
					break
				end switch

				foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)	
					if Green.Shit == 1
						BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
						if checkResult == 1
							if Delta_Attacker == 0
								Delta_SlenderMercy += 5
							else
								Delta_FreddyMercy += 5
								if Delta_HP < 90
									Delta_HP += 2
								end if								
							end if
							if ringPan == 0
								PlaySfx(SfxName[Ring L], 0)
								SetSfxAttributes(SfxName[Ring L], -1, -100)
								ringPan = 1
							else
								PlaySfx(SfxName[Ring R], 0)
								SetSfxAttributes(SfxName[Ring R], -1, 100)
								ringPan = 0
							end if			
							Delta_ShowMercy = 1			
							Object.TableContainer = 0
							object.type = TypeName[Blank Object]	
						end if
					else
						if object[currentPlayer].value6 == 0
							BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
							if checkResult == 1
								if Delta_Defending == 1
									Delta_HP--
								else
									Delta_HP -= 2
								end if
								PlaySfx(SfxName[Hurt], 0)
								object[40].AnimationTimer = 80
								object[40].Animation = 2
								object[currentPlayer].value6	= 80
							end if
						end if
					end if
				next
			break
			case FREDDYATTACKS_LEFTTOSS_3
				switch object.state
					case 0
						if Delta_AttackHardMode == 1
							Wait.Time = 15
						else
							Wait.Time = 20
						end if

						Attack.Timer++
						if Attack.Timer >= Wait.Time
							temp1 = screen.xcenter
							temp1 -= 0x8000
							temp2 = object[currentPlayer].ypos

							if Delta_BecomeGreen == 1
								rand(Mercy.Attack, 6)		//6 =	0, 1, 2, 3, 4, 5
								if Mercy.Attack == 5	//25% chance
									Mercy.Attack = 1
								end if
							end if
						
							
							CreateTempObject(TypeName[Freddy Attacks], 3, temp1, temp2)
							if Mercy.Attack == 1
								Green.Shit = 1
							end if
							object.state++	
							

							Attack.Timer = 0
						end if	
					//ok so there should usually be a break here but like, it kinda makes it work not as good??
					//but idk if this would do anything back
					case 1	//normal evil attack
						object.timer++

						if object.timer <= 150
							object.rotation += 12
							object.xvel += 0x2000
							if object.xvel > 0x40000
								object.xvel = 0x40000
							end if	
						else
							object.rotation -= 12
							object.xvel -= 0x600	//left?? i have no clue
							if object.xvel > 0x8000
								object.xvel = 0x8000
							end if		
						end if


						if object.timer == 200
							object.type = TypeName[Blank Object]
							object.timer = 0	
						end if
					break
				end switch

				foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)	
					if Green.Shit == 1
						BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
						if checkResult == 1
							if Delta_Attacker == 0
								Delta_SlenderMercy += 5
							else
								Delta_FreddyMercy += 5
								if Delta_HP < 90
									Delta_HP += 2
								end if								
							end if
							if ringPan == 0
								PlaySfx(SfxName[Ring L], 0)
								SetSfxAttributes(SfxName[Ring L], -1, -100)
								ringPan = 1
							else
								PlaySfx(SfxName[Ring R], 0)
								SetSfxAttributes(SfxName[Ring R], -1, 100)
								ringPan = 0
							end if			
							Delta_ShowMercy = 1			
							Object.TableContainer = 0
							object.type = TypeName[Blank Object]	
						end if
					else
						if object[currentPlayer].value6 == 0
							BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
							if checkResult == 1
								if Delta_Defending == 1
									Delta_HP--
								else
									Delta_HP -= 2
								end if
								PlaySfx(SfxName[Hurt], 0)
								object[40].AnimationTimer = 80
								object[40].Animation = 2
								object[currentPlayer].value6	= 80
							end if
						end if
					end if
				next
			break	
			case FREDDYATTACKS_HARHAR_4
				temp0 = object[currentPlayer].iypos
				flipsign(temp0)
				object.rotation = temp0
				switch object.state
				case 0

					if Delta_AttackHardMode == 1
						Wait.Time = 50
					else
						Wait.Time = 75
					end if

					Attack.Timer++
					if Attack.Timer >= Wait.Time
						temp1 = screen.xcenter
						temp1 *= 0x19000
						temp2 = Screen.ycenter
						temp2 *= 0x10000
						PlaySfx(SfxName[Har1], 0)

						if Delta_BecomeGreen == 1
							rand(Mercy.Attack, 4)		//4 =	0, 1, 2, 3
							if Mercy.Attack == 3	//25% chance
								Mercy.Attack = 1
							end if
						end if
					
						CreateTempObject(TypeName[Freddy Attacks], 4, temp1, temp2)
						if Mercy.Attack == 1
							Green.Shit  = 1
						end if

						object.state++	
						object[tempObjectPos].drawOrder = 6	
						
						Attack.Timer = 0
					end if	
					
				case 1
					object.timer++

					if object.timer <= 150
						object.xvel -= 0x600	//left?? i have no clue
						if object.xvel > 0x8000
							object.xvel = 0x8000
						end if	
					else
						if Green.Shit == 1
							object.xvel += 0x2000
							if object.xvel > 0x40000
								object.xvel = 0x40000
							end if	
						end if
					end if


					CheckGreater(object.ypos, object[currentPlayer].ypos)
					temp0 = checkResult

					if temp0 == 1		//right
						if object.yvel > 0
							object.yvel -= 0x2000	
						else
							object.yvel -= 0x1500	
						end if		
					else		//down
						if object.yvel < 0
							object.yvel += 0x2000
						else
							object.yvel += 0x1500
						end if
					end if	


					if object.timer == 400
						object.type = TypeName[Blank Object]
						object.timer = 0	
					end if
				break
				end switch

				foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)	
					if Green.Shit == 1
						BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
						if checkResult == 1
							if Delta_Attacker == 0
								Delta_SlenderMercy += 5
							else
								Delta_FreddyMercy += 5
								if Delta_HP < 90
									Delta_HP += 2
								end if								
							end if
							if ringPan == 0
								PlaySfx(SfxName[Ring L], 0)
								SetSfxAttributes(SfxName[Ring L], -1, -100)
								ringPan = 1
							else
								PlaySfx(SfxName[Ring R], 0)
								SetSfxAttributes(SfxName[Ring R], -1, 100)
								ringPan = 0
							end if			
							Delta_ShowMercy = 1			
							Object.TableContainer = 0
							object.type = TypeName[Blank Object]	
						end if
					else
						if object[currentPlayer].value6 == 0
							BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
							if checkResult == 1
								if Delta_Defending == 1
									Delta_HP--
								else
									Delta_HP -= 2
								end if
								PlaySfx(SfxName[Hurt], 0)
								object[40].AnimationTimer = 80
								object[40].Animation = 2
								object[currentPlayer].value6	= 80
							end if
						end if
					end if
				next
			break	
			case FREDDYATTACKS_PIZZAWHEEL_5
				switch object.state
					case 0
						object.xpos = object[currentPlayer].xpos
						temp2 = Screen.ycenter
						temp2 += 0x200000
						object.ypos = temp2
						object.state++
						object.xpos = object[currentPlayer].xpos
					case 1
						Object.Timer++

						if object.timer <= 10
							object.xpos = object[currentPlayer].xpos
						end if	

						if object.timer >= 25
							object.yvel += 3800
						end if

						if object.timer >= 78
							object.yvel = -80000
							PlaySfx(SfxName[Thud], 0)

							CheckGreater(object.xpos, object[currentPlayer].xpos)
							temp0 = checkResult
							if temp0 == 1		//right
								if object.xvel > 0
									object.xvel -= 0x1000	//right
									if object.xvel > 0x4000
										object.xvel = 0x4000
									end if
								else
									object.xvel -= 0x500	//left?? i have no clue
									if object.xvel > 0x5000
										object.xvel = 0x5000
									end if			
								end if
							else	//left
								if object.xvel < 0
									object.xvel += 0x2000
									if object.xvel > 0x4000
										object.xvel = 0x4000
									end if		
								else
									object.xvel += 0x1500
									if object.xvel > 0x4000
										object.xvel = 0x4000
									end if								
								end if
							end if

							//stupid pizza bits
							CreateTempObject(TypeName[Freddy Attacks], 5, object.xpos, object.ypos)
							object[tempObjectPos].yvel = -120000
							object[tempObjectPos].state = 3
							object[tempObjectPos].Value7 = 0

							//stupid mercy stuff
							if Delta_BecomeGreen == 1
								rand(Object[tempObjectPos].Value2, 4)		//4 =	0, 1, 2, 3
								if Object[tempObjectPos].Value2 == 3	//25% chance
									Object[tempObjectPos].Value2 = 1
								end if
							end if

							CreateTempObject(TypeName[Freddy Attacks], 5, object.xpos, object.ypos)
							object[tempObjectPos].yvel = -120000
							object[tempObjectPos].state = 3
							object[tempObjectPos].Value7 = 1

							if Delta_BecomeGreen == 1
								rand(Object[tempObjectPos].Value2, 4)		//4 =	0, 1, 2, 3
								if Object[tempObjectPos].Value2 == 3	//25% chance
									Object[tempObjectPos].Value2 = 1
								end if
							end if

							CreateTempObject(TypeName[Freddy Attacks], 5, object.xpos, object.ypos)
							object[tempObjectPos].yvel = -120000
							object[tempObjectPos].state = 3
							object[tempObjectPos].Value7 = 2

							if Delta_BecomeGreen == 1
								rand(Object[tempObjectPos].Value2, 4)		//4 =	0, 1, 2, 3
								if Object[tempObjectPos].Value2 == 3	//25% chance
									Object[tempObjectPos].Value2 = 1
								end if
							end if

							CreateTempObject(TypeName[Freddy Attacks], 5, object.xpos, object.ypos)
							object[tempObjectPos].yvel = -120000
							object[tempObjectPos].state = 3
							object[tempObjectPos].Value7 = 3

							if Delta_BecomeGreen == 1
								rand(Object[tempObjectPos].Value2, 4)		//4 =	0, 1, 2, 3
								if Object[tempObjectPos].Value2 == 3	//25% chance
									Object[tempObjectPos].Value2 = 1
								end if
							end if

							object.state++
							object.timer = 0
						end if
					break
					case 2
						object.yvel += 4800
						if object.outofbounds == 1
							object.xvel = 0
							object.yvel = 0
							object.state = 0	
						end if	
					break
					case 3
						object.yvel += 2400
						switch object.Value7
							case 0
								object.xvel = -0x4000
							break
							case 1
								object.xvel = 0x4000
							break			
							case 2
								object.xvel = 0x68	00
							break												
						end switch
						if object.outofbounds == 1
							object.type = TypeName[Blank Object]
						end if
					break
				end switch


				foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)	
					if object.state == 3
						if mercy.attack == 1
							BoxCollisionTest(C_TOUCH, object.entityPos, -4, -4, 4, 4, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
							if checkResult == 1
								if Delta_Attacker == 0
									Delta_SlenderMercy += 5
								else
									Delta_FreddyMercy += 5
									if Delta_HP < 90
										Delta_HP += 2
									end if									
								end if
								if ringPan == 0
									PlaySfx(SfxName[Ring L], 0)
									SetSfxAttributes(SfxName[Ring L], -1, -100)
									ringPan = 1
								else
									PlaySfx(SfxName[Ring R], 0)
									SetSfxAttributes(SfxName[Ring R], -1, 100)
									ringPan = 0
								end if			
								Delta_ShowMercy = 1			
								Object.TableContainer = 0
								object.type = TypeName[Blank Object]	
							end if
						else
							if object[currentPlayer].value6 == 0
								BoxCollisionTest(C_TOUCH, object.entityPos, -4, -4, 4, 4, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
								if checkResult == 1
									if Delta_Defending == 1
										Delta_HP--
									else
										Delta_HP -= 2
									end if
									PlaySfx(SfxName[Hurt], 0)
									object[40].AnimationTimer = 80
									object[40].Animation = 2
									object[currentPlayer].value6	= 80
								end if
							end if
						end if
					else
						if object[currentPlayer].value6 == 0
							BoxCollisionTest(C_TOUCH, object.entityPos, -18, -18, 18, 18, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
							if checkResult == 1
								if Delta_Defending == 1
									Delta_HP--
								else
									Delta_HP -= 2
								end if
								PlaySfx(SfxName[Hurt], 0)
								object[40].AnimationTimer = 80
								object[40].Animation = 2
								object[currentPlayer].value6	= 80
							end if
						end if
					end if
				next

			break		
		end switch
	end if
else
	if object[40].state > 6
		object.type = TypeName[Blank Object]
	end if
end if
end event

event ObjectDraw
if object[40].state == 6
	if Delta_Attacker == 0	//slen
		switch object.propertyValue
			case 0
			case 1
				CheckEqual(Mercy.Attack, 1)
				temp1 = checkResult
				CheckEqual(object.state, 2)
				temp1 |= checkResult			
				if temp1 == 1
					DrawSpriteXY(1, Object.Xpos, Object.Ypos)
				else
					DrawSpriteXY(0, Object.Xpos, Object.Ypos)
				end if
			break
			case 2
			case 3
				switch object.state 
					case 1
						DrawSpriteXY(2, Object.Xpos, Object.Ypos)
					break
					case 2
						DrawSpriteXY(3, Object.Xpos, Object.Ypos)
					break			
					case 3
						DrawSpriteXY(4, Object.Xpos, Object.Ypos)
					break			
				end switch
			break
			case 4
				object.inkeffect = INK_ALPHA
				DrawSpriteFX(6, FX_INK, Object.Xpos, Object.Ypos)
			break
			case 5
				object.inkeffect = INK_ALPHA
				DrawSpriteFX(7, FX_INK, Object.Xpos, Object.Ypos)
			break	
			case 6
				object.inkeffect = INK_ALPHA
				DrawSpriteFX(8, FX_INK, Object.Xpos, Object.Ypos)
			break	
			case 7
			case 8
				object.inkeffect = INK_ALPHA
				DrawSpriteFX(9, FX_INK, Object.Xpos, Object.Ypos)
			break		
		end switch
	else
		switch object.propertyValue
			case 0
			case 1
				CheckEqual(Mercy.Attack, 1)
				temp1 = checkResult
				CheckEqual(object.state, 2)
				temp1 |= checkResult			
				if temp1 == 1
					DrawSpriteXY(11, Object.Xpos, Object.Ypos)
				else
					DrawSpriteXY(10, Object.Xpos, Object.Ypos)
				end if
			break 
			case 2
				if Green.Shit  == 1
					DrawSpriteFX(13, FX_ROTATE, Object.Xpos, Object.Ypos)
				else
					DrawSpriteFX(12, FX_ROTATE, Object.Xpos, Object.Ypos)
				end if
			break
			case 3
				if Green.Shit  == 1
					DrawSpriteFX(13, FX_ROTATE, Object.Xpos, Object.Ypos)
				else
					DrawSpriteFX(16, FX_ROTATE, Object.Xpos, Object.Ypos)
				end if
			break
			case 4
				if Green.Shit  == 1
					DrawSpriteFX(13, FX_ROTATE, Object.Xpos, Object.Ypos)
				else
					DrawSpriteFX(15, FX_ROTATE, Object.Xpos, Object.Ypos)
				end if
			break
			case 5
				switch object.state	
				case 1
				case 2
					if object.state == 1
						if object.timer >= 11
							DrawSpriteFX(18, FX_ROTATE, Object.Xpos, Object.Ypos)
						end if
					else
						DrawSpriteFX(18, FX_ROTATE, Object.Xpos, Object.Ypos)
					end if
				break
				case 3
					CheckEqual(Mercy.Attack, 1)
					temp1 = checkResult
					if temp1 == 1
						DrawSpriteXY(11, Object.Xpos, Object.Ypos)
					else
						DrawSpriteXY(10, Object.Xpos, Object.Ypos)
					end if				
				break
				end switch
			break
		end switch
	end if
end if
end event

event ObjectStartup
	LoadSpriteSheet("3D_Test/DeltaSheet.gif")
	SpriteFrame(-5, -5, 10, 10, 136, 49)	//Thing	0
	SpriteFrame(-5, -5, 10, 10, 147, 49)	//Green Page	0
	SpriteFrame(-10, -3, 20, 71, 415, 131)	//watch out 2
	SpriteFrame(-10, -3, 20, 71, 394, 131)	//thunda 3
	SpriteFrame(-10, -3, 20, 71, 373, 131)	//page... 4
	SpriteFrame(-36, 0, 73, 72, 353, 203)	//5 tree attack

	SpriteFrame(-12, 24, 24, 72, 328, 203)	//6 tree up
	SpriteFrame(-12, 24, 24, 72, 366, 301)	//7 tree down	
	SpriteFrame(24, -12, 72, 24, 354, 276)	//8 tree up
	SpriteFrame(24, -12, 72, 24, 391, 357)	//9 tree up		

	SpriteFrame(-5, -5, 10, 10, 464, 357)	//pizza	10
	SpriteFrame(-5, -5, 10, 10, 475, 357)	//Green gizza	11	

	SpriteFrame(-8, -12, 16, 24, 488, 357)	//mic toss WERE SO BACK 12
	SpriteFrame(-8, -12, 16, 24, 396, 382)	//green pizza 13	

	SpriteFrame(-11, -5, 23, 11, 464, 368)	//har 14	
	SpriteFrame(-5, -11, 11, 23, 464, 380)	//v har 15		

	SpriteFrame(-8, -12, 16, 24, 413, 382)	//norm pizza 16

	SpriteFrame(-32, -32, 64, 64, 301, 310)	//norm pizza 17	
	SpriteFrame(-24, -24, 48, 48, 243, 212)	//norm pizza 18		
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("IIZ/Objects1.gif")
	SpriteFrame(0, 0, 64, 64, 153, 154)
end event
